package bookManage;

import java.util.ArrayList;
import java.util.Scanner;

public class Card {

	static ArrayList<CardModel> cards = new ArrayList<CardModel>();// 借阅卡
	static Scanner scanner = new Scanner(System.in);

	static int userId;// 本次登录用户id

	/**
	 * 修改密码
	 */
	public void updatePsw() {
		CardModel cardModel = new CardModel();

		System.out.println("=======修改密码=======");
		System.out.print("请输入借阅卡id：");
		int id = Integer.parseInt(scanner.nextLine());
		System.out.print("请输入原密码：");
		String psw = scanner.nextLine();
		System.out.print("请输入新密码：");
		String newPsw = scanner.nextLine();

		cardModel.updatePsw(id, psw, newPsw);
	}

	/**
	 * 借阅图书
	 */
	public void borrowBook() {
		BookModel bookModel = new BookModel();
		bookModel.selectAll();// 显示全部图书

		System.out.println("请输入借阅图书名：");
		String bookName = scanner.nextLine();

		bookModel.selectByName(bookName);// 查询相关图书
		System.out.println("请输入借阅的图书id：");
		int id = Integer.parseInt(scanner.nextLine());

		BorrowModel borrowModel = new BorrowModel();
		borrowModel.addBorrow(id);
		borrowModel.selectAll();

	}
	
	/**
	 * 归还图书
	 */
	public void rebackBook() {
		BorrowModel borrowModel = new BorrowModel();

		System.out.println("已借阅图书：");
		borrowModel.selectAll();
		
		System.out.println("请输入归还的图书id：");
		int id = Integer.parseInt(scanner.nextLine());

		RebackModel rebackModel = new RebackModel();
		rebackModel.addReback(id);
		rebackModel.selectAll();

	}

}
